package com.hotelManagerSystem.mapper;

import com.hotelManagerSystem.model.RoomOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.context.annotation.Primary;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Cynthia
 * @since 2021-12-22
 */
@Primary
public interface RoomOrderMapper extends BaseMapper<RoomOrder> {

    @Update("update room_order set order_state= 1 where room_order_id=#{roomOrderId}")
    int updateStateById(int roomOrderId);

    @Select("select * from room_order where order_state=#{orderState}")
    List<RoomOrder> queryInfoByState(int orderState);

    @Select("select * from room_order where uid=#{uid}")
    List<RoomOrder> queryInfoByUsername(Integer uid);

    @Select("select * from room_order where uid=#{uid} and order_state=#{orderState}")
    List<RoomOrder> queryInfoByUsernameAndState(Integer uid, Integer orderState);


    @Select("SELECT * FROM `room_order` WHERE order_num LIKE concat('%',#{orderNum_s},'%')")
    List<RoomOrder> queryRoomOrderByOrderNum(String orderNum_s);
}
